﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Jage.Common
{
    public class Configuration
        : SavableObject<Configuration>
    {

        private const string Filename = "configuration.xml";

        private static Configuration _default;
        public static Configuration Default
        {
            get
            {
                if (_default == null)
                {
                    if (File.Exists(Filename))
                    {
                        _default = Configuration.LoadFromFile(Filename);
                    }
                    else
                    {
                        _default = GetDefaultConfiguration();
                        Configuration.SaveToFile(Filename, _default);
                    }
                }
                return _default;
            }
        }

        private static Configuration GetDefaultConfiguration()
        {
            return new Configuration() { DatabaseFilename = string.Empty, ResourcePath = string.Empty };
        }

        public string DatabaseFilename { get; set; }

        public string ResourcePath { get; set; }

    }
}
